<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="./lib/vue.js" type="text/javascript" charset="utf-8"></script>
        <title>Document</title>
    </head>
    <body>
        <div id="app">
            <ul>
                <!-- 从父组件传值到子组件 -->
                <product-com v-for="(item,index) in proList" :product="item"></product-com>
            </ul>
        </div>
    </body>
    <script>
        // 产品组件
        Vue.component("product-com", {
            // 通过 Prop 向子组件传递数据
            props: ["product"],
            template:`<li>
                        <h2>产品名称:{{ product.title }}</h2>
                        <h3>产品描述:{{ product.brief }}</h3>
                        <p>产品价格:{{ product.price }}</p>
                    </li>`
        })
        // 根组件
        let app = new Vue({
            el:"#app",
            data:{
                proList:[
                    {
                        title:"产品1",
                        price:"10",
                        brief:"产品描述1"
                    },
                    {
                        title:"产品2",
                        price:"20",
                        brief:"产品描述2"
                    },
                    {
                        title:"产品3",
                        price:"30",
                        brief:"产品描述3"
                    },
                    {
                        title:"产品4",
                        price:"40",
                        brief:"产品描述4"
                    },
                    {
                        title:"产品5",
                        price:"50",
                        brief:"产品描述5"
                    }
                ]
            }
        })
    </script>
</html>